package gui;

import gui.arp.ArpPanel;

import java.awt.Color;
import java.awt.Font;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import data.ArpTemplate;
import data.ChordTemplate;
import data.DeviceProperties;
import data.EchoTemplate;
import data.RandomTemplate;

@SuppressWarnings("serial")
public class MainFrame extends JFrame {
	private ArpPanel arpPanel;
	private DevicePanel devPanel;
	private ChordPanel chdPanel;
	private EchoPanel echPanel;
	private RandomPanel rndPanel;
	private JTabbedPane tabPane;
	private Color fgColor = Color.GREEN;
	private Color bgColor = Color.BLACK;
	private Font font;
	
	public MainFrame() {
		super("MIDIFX");
		this.setSize(800, 600);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		// TODO: Install font where unavailable
		//String fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
		//for (String s: fonts) System.out.println(s);
		font = new Font("DS-Digital", Font.PLAIN, 20);
		
		ArpTemplate template = new ArpTemplate(1, "1/16");
		arpPanel = new ArpPanel(fgColor, bgColor, font, template);
		
		ChordTemplate ctemplate = new ChordTemplate(6);
		chdPanel = new ChordPanel(fgColor, bgColor, font, ctemplate);
		
		EchoTemplate etemplate = new EchoTemplate();
		echPanel = new EchoPanel(fgColor, bgColor, font, etemplate);
		
		RandomTemplate rtemplate = new RandomTemplate();
		rndPanel = new RandomPanel(fgColor, bgColor, font, rtemplate);
		
		tabPane = new JTabbedPane();
		
		// TODO: Extend or implement BasicTabbedPaneUI
		//tabPane.setBackground(bgColor);
		//tabPane.setForeground(fgColor);
		tabPane.setFont(font);
		tabPane.addTab("Arpeggiator", arpPanel);
		tabPane.addTab("Chord", chdPanel);
		tabPane.addTab("Echo", echPanel);
		tabPane.addTab("Random", rndPanel);
		
		DeviceProperties devProps = new DeviceProperties();
		devPanel = new DevicePanel(fgColor, bgColor, font, devProps, rtemplate, etemplate, ctemplate, template, tabPane);
		
		JPanel panel = new JPanel();
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
		panel.add(tabPane);
		panel.add(devPanel);
		this.add(panel);
		/*JScrollPane scrollPane = new JScrollPane();
		scrollPane.add(devPanel);
		scrollPane.add(arpPanel);
		this.add(scrollPane);*/
		
		this.pack();
		this.setVisible(true);
	}
}
